﻿@using System.Diagnostics.CodeAnalysis
@using Microsoft.Extensions.Options
@using Project.Constraints.Options
@using Project.Constraints.Store.Models
@using Project.Constraints.UI
@using Project.Web.Shared.Components
@using Project.AppCore
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8" no-antblazor-js no-antblazor-css />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <base href="/" />
    @* <link href="@Assets[UIService.MainStyle()]" rel="stylesheet"> *@
    <VLink Href="@UIService.MainStyle()"></VLink>
    <link data-dark rel="stylesheet">
    @* <script src="@Assets[UIService.UIFrameworkJs()]"></script> *@
    <VScript Src="@UIService.UIFrameworkJs()"></VScript>
    @* <link href="@Assets["app.css"]" rel="stylesheet" /> *@
    <VLink Href="app.css"></VLink>
    @* <link href="@Assets["BlazorAdmin.styles.css"]" rel="stylesheet" /> *@
    <VLink Href="BlazorAdmin.styles.css"></VLink>
    <HeadOutlet @rendermode="@RenderMode" />
</head>

<body>

    <Routers RenderMode="@RenderMode"></Routers>
    <Project.Web.Shared.Components.ReconnectorOutlet @rendermode="@RenderMode"></Project.Web.Shared.Components.ReconnectorOutlet>

    @* <script src="@Assets["_framework/blazor.web.js"]"></script> *@
    <VScript Src="_framework/blazor.web.js"></VScript>
    @* <script src="@Assets["js/blazor-admin-project.js"]"></script> *@
    <VScript Src="js/blazor-admin-project.js"></VScript>
</body>

</html>

@code {
    [CascadingParameter, NotNull] public HttpContext? HttpContext { get; set; }
    [Inject, NotNull] public IOptions<AppSetting>? AppOption { get; set; }
    [Inject, NotNull] public IOptions<Token>? TokenOption { get; set; }
    [Inject, NotNull] public IUIService? UIService { get; set; }
    IComponentRenderMode? RenderMode
    {
        get
        {
            if (!HttpContext.AcceptsInteractiveRouting())
            {
                return null;
            }
            return AppOption.Value.RunMode switch
            {
                AppRunMode.Auto => new InteractiveAutoRenderMode(false),
                AppRunMode.Server => new InteractiveServerRenderMode(false),
                AppRunMode.WebAssembly => new InteractiveWebAssemblyRenderMode(false),
                _ => throw new ArgumentException()
            };
        }
    }
}